﻿using System;

namespace Lib.MonitLogs.Entitys;
/// <summary>
/// 
/// </summary>
internal class LogException {
    /// <summary>
    /// 创建对象
    /// </summary>
    public static LogException Create(Exception Ex, string Description = null) {
        var Re = new LogException {
            Description = Description,
            Date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
            Message = Ex.Message,
            InnerException = Ex.InnerException?.Message,
            Source = Ex.Source,
            StackTrace = Ex.StackTrace,
            TargetSite = $"{Ex.TargetSite?.DeclaringType?.FullName}.{Ex.TargetSite?.Name}"
        };
        return Re;
    }
    /// <summary>
    /// 
    /// </summary>
    public LogException() { }
    /// <summary>
    /// 日志时间
    /// </summary>
    public string Date { get; set; }
    /// <summary>
    /// 摘要信息
    /// </summary>
    public string Description { get; set; }
    /// <summary>
    /// 异常信息
    /// </summary>
    public string Message { get; set; }
    /// <summary>
    /// 具体原因
    /// </summary>
    public string InnerException { get; set; }
    /// <summary>
    /// 异常对象
    /// </summary>
    public string Source { get; set; }
    /// <summary>
    /// 调用堆栈
    /// </summary>
    public string StackTrace { get; set; }
    /// <summary>
    /// 触发方法
    /// </summary>
    public string TargetSite { get; set; }
}

